Minor optimizations to Resize.#3044
Merged
JimBobSquarePants merged 3 commits intomainfrom Jan 20, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request introduces performance optimizations to the resize processing pipeline through ref-walking and loop unrolling techniques, along with updates to the benchmarking infrastructure for improved accuracy and compatibility.
Changes:
- Optimized horizontal and vertical kernel operations in
ResizeWorker.csusing ref-walking and loop unrolling to reduce bounds checks and inner-loop overhead - Added
GetKernelSpan()method toResizeKernelMap.csto facilitate efficient ref-walking - Updated BenchmarkDotNet packages from 0.14.0 to 0.15.8 and added Visual Studio diagnostics support
- Introduced
StandardInProcessbenchmark configuration usingInProcessEmitToolchainfor more accurate in-process benchmarking
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs | Implemented ref-walking and loop unrolling optimizations in FillDestinationPixels and CalculateFirstPassValues methods to reduce bounds checks and loop overhead |
| src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs | Added GetKernelSpan() method to expose kernel data as ReadOnlySpan for efficient ref-walking |
| tests/ImageSharp.Benchmarks/Config.cs | Added new StandardInProcess configuration class using InProcessEmitToolchain |
| tests/ImageSharp.Benchmarks/Processing/Resize.cs | Updated benchmark to use StandardInProcess configuration |
| tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj | Updated BenchmarkDotNet packages to 0.15.8 and added Visual Studio diagnostics package |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
This pull request introduces performance optimizations to the resize processing pipeline in ImageSharp, primarily by reducing bounds checks and loop overhead through ref-walking and loop unrolling techniques. Additionally, the benchmark configuration is updated to use in-process execution and newer BenchmarkDotNet packages for improved benchmarking accuracy and compatibility.
Resize Pipeline Performance Optimizations
ResizeWorker.csfor both horizontal and vertical kernel operations, reducing bounds checks and inner-loop overhead inFillDestinationPixelsandCalculateFirstPassValues. This results in more efficient memory access and faster pixel processing.GetKernelSpan()is added toResizeKernelMap.cs, providing a read-only span over kernel data to facilitate efficient ref-walking in tight loops.Benchmarking Improvements
InProcessEmitToolchainfor more accurate in-process benchmarking, and a newStandardInProcessconfig class is introduced.Main
This PR